package com.admin.business.background.venusOaControlOverInvoices;

import com.tiangong.framework.annotation.OpenApi;
import com.tiangong.framework.bo.CDO;
import com.tiangong.framework.bo.Return;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @description: 发票管理表
 * @create: 2023-11-01 13:39:23
 **/
@Service("venusOaControlOverInvoicesService")
@Slf4j
public class VenusOaControlOverInvoicesService{

    @Resource
    VenusOaControlOverInvoicesDao venusOaControlOverInvoicesDao;

    /**
     * 添加发票管理表,获取id数据
     *
     * @param cdoRequest - id:发票id
     *                   - code:检验是否开票的唯一标识
     *                   - user_id:上传人id
     *                   - owner_id:业主id
     *                   - room_id:房间号id
     *                   - invoice_status:发票状态:1、未开票，2、待开票，3、已开票
     *                   - company_id:公司id
     *                   - project_id:项目id
     *                   - publish_location:发布位置
     *                   - fee_id:关联id
     *                   - fee_name:费用类型
     *                   - invoice_type:发票类型:1、增值税普通发票（纸质发票），2、增值税专用发票（纸质发票）,3、增值税普通发票（电子版），4、增值税专用发票（电子版）
     *                   - prompt_for_invoice:是否提示开发票:0、是，1、否
     *                   - pay_time:缴费时间
     *                   - amount_of_money:金额
     *                   - head_up_type:抬头类型:1、个人，2、企业
     *                   - rise:抬头：企业名称
     *                   - taxpayer_identification_code:纳税人识别码
     *                   - rise_address:地址
     *                   - rise_telephone:电话
     *                   - bank_of_deposit:开户行
     *                   - account_number:账号
     *                   - invoice_remarks:备注
     *                   - invoice_photo_first:发票照片第一张
     *                   - invoice_photo_last:发票照片第二张
     *                   - ticket_collection_method:取票方式:1、自取，2、快递，3、邮箱
     *                   - ticket_collector_email:取票人邮箱
     *                   - ticket_collector_name:取票人姓名
     *                   - ticket_collector_phone:取票人电话
     *                   - detailed_address:详细地址
     *                   - express_name:快递名称
     *                   - courier_number:快递单号
     *                   - express_image:快递图片
     *                   - courier_remarks:快递备注
     *                   - uploader_name:开票人姓名
     *                   - upload_time:开票时间
     *                   - confirm_the_people:确认人
     *                   - confirm_the_time:确认时间
     *                   - confirm_the_image:确认图片
     *                   - confirm_the_content:确认备注
     *                   - update_time:更新时间
     *                   - begin_time:申请时间
     *                   - state:是否删除：0、正常，1、已删除；
     * @return
     * @author Ht
     * @create: 2023-11-01 13:39:23
     */
    @OpenApi
    public Return addVenusOaControlOverInvoices(CDO cdoRequest) {
        venusOaControlOverInvoicesDao.addVenusOaControlOverInvoices(cdoRequest);
        CDO cdoResult = new CDO();
        if (cdoRequest.containsKey("id")) {
            cdoResult.set("id", cdoRequest.get("id"));
        }
        return Return.valueOf(cdoResult);
    }

    /**
     * 根据id，更新发票管理表数据
     *
     * @param cdoRequest - id:发票id
     *                   - code:检验是否开票的唯一标识
     *                   - user_id:上传人id
     *                   - owner_id:业主id
     *                   - room_id:房间号id
     *                   - invoice_status:发票状态:1、未开票，2、待开票，3、已开票
     *                   - company_id:公司id
     *                   - project_id:项目id
     *                   - publish_location:发布位置
     *                   - fee_id:关联id
     *                   - fee_name:费用类型
     *                   - invoice_type:发票类型:1、增值税普通发票（纸质发票），2、增值税专用发票（纸质发票）,3、增值税普通发票（电子版），4、增值税专用发票（电子版）
     *                   - prompt_for_invoice:是否提示开发票:0、是，1、否
     *                   - pay_time:缴费时间
     *                   - amount_of_money:金额
     *                   - head_up_type:抬头类型:1、个人，2、企业
     *                   - rise:抬头：企业名称
     *                   - taxpayer_identification_code:纳税人识别码
     *                   - rise_address:地址
     *                   - rise_telephone:电话
     *                   - bank_of_deposit:开户行
     *                   - account_number:账号
     *                   - invoice_remarks:备注
     *                   - invoice_photo_first:发票照片第一张
     *                   - invoice_photo_last:发票照片第二张
     *                   - ticket_collection_method:取票方式:1、自取，2、快递，3、邮箱
     *                   - ticket_collector_email:取票人邮箱
     *                   - ticket_collector_name:取票人姓名
     *                   - ticket_collector_phone:取票人电话
     *                   - detailed_address:详细地址
     *                   - express_name:快递名称
     *                   - courier_number:快递单号
     *                   - express_image:快递图片
     *                   - courier_remarks:快递备注
     *                   - uploader_name:开票人姓名
     *                   - upload_time:开票时间
     *                   - confirm_the_people:确认人
     *                   - confirm_the_time:确认时间
     *                   - confirm_the_image:确认图片
     *                   - confirm_the_content:确认备注
     *                   - update_time:更新时间
     *                   - begin_time:申请时间
     *                   - state:是否删除：0、正常，1、已删除；
     * @return
     * @author Ht
     * @create: 2023-11-01 13:39:23
     */
    @OpenApi
    public Return updateVenusOaControlOverInvoicesById(CDO cdoRequest) {
        venusOaControlOverInvoicesDao.updateVenusOaControlOverInvoicesById(cdoRequest);
        return Return.SUCCESS;
    }

    /**
     * 根据id，删除发票管理表数据
     *
     * @param cdoRequest - id:发票id
     * @return
     * @author Ht
     * @create: 2023-11-01 13:39:23
     */
    @OpenApi
    public Return deleteVenusOaControlOverInvoicesById(CDO cdoRequest){
        int count = venusOaControlOverInvoicesDao.deleteVenusOaControlOverInvoicesById(cdoRequest.getLong("id"));
        CDO cdoResult = new CDO();
        cdoResult.set("count", count);
        return Return.valueOf(cdoResult);
    }

    /**
     * 根据条件，删除发票管理表数据
     *
     * @param cdoRequest
     * @return
     * @author Ht
     * @create: 2023-11-01 13:39:23
     */
    @OpenApi
    public Return deleteVenusOaControlOverInvoices(CDO cdoRequest) {
        int count = venusOaControlOverInvoicesDao.deleteVenusOaControlOverInvoices(cdoRequest);
        CDO cdoResult = new CDO();
        cdoResult.set("count", count);
        return Return.valueOf(cdoResult);
    }

    /**
     * 根据ID，获取发票管理表数据
     *
     * @param cdoRequest - id:发票id
     * @return
     * @author Ht
     * @create: 2023-11-01 13:39:23
     */
    @OpenApi
    public Return getVenusOaControlOverInvoicesById(CDO cdoRequest) {
        CDO cdoMapperResult = venusOaControlOverInvoicesDao.getVenusOaControlOverInvoicesById(cdoRequest.getLong("id"));
        return Return.valueOf(cdoMapperResult);
    }

    /**
     * 根据非空条件，获取发票管理表数据列表
     *
     * @param cdoRequest
     * @return
     * @author Ht
     * @create: 2023-11-01 13:39:23
     */
    @OpenApi
    public Return getVenusOaControlOverInvoicesListPage(CDO cdoRequest) {
        Integer pageIndex = cdoRequest.getInteger("pageIndex")-1;
        int recordSize = 10;
        cdoRequest.set("recordFrom", pageIndex * recordSize);
        cdoRequest.set("recordSize", recordSize);
        List<CDO> cdoMapperResultList = venusOaControlOverInvoicesDao.getVenusOaControlOverInvoicesListPage(cdoRequest);
        boolean isEndPage = false;
        if (cdoMapperResultList.size() < recordSize) {
            isEndPage = true;
        }
        CDO cdoResult = new CDO();
        cdoResult.set("isEndPage", isEndPage);
        cdoResult.set("datalist", cdoMapperResultList);
//        int total = venusOaControlOverInvoicesDao.getVenusOaControlOverInvoicesCount(cdoRequest);
//        cdoResult.set("total", total);
        return Return.valueOf(cdoResult);
    }
    /**
     * 根据混合条件，获取发票管理表数据列表
     *
     * @param cdoRequest - id:发票id
     * @return
     * @author Ht
     * @create: 2023-11-01 13:39:23
     */
    @OpenApi
    public Return getVenusOaControlOverInvoicesListPageByCondition(CDO cdoRequest) {
        Integer pageIndex = cdoRequest.getInteger("pageIndex")-1;
        int recordSize = 10;
        cdoRequest.set("recordFrom", pageIndex * recordSize);
        cdoRequest.set("recordSize", recordSize);
        List<CDO> cdoMapperResultList = venusOaControlOverInvoicesDao.getVenusOaControlOverInvoicesListPageByCondition(cdoRequest);
        boolean isEndPage = false;
        if (cdoMapperResultList.size() < recordSize) {
            isEndPage = true;
        }
        CDO cdoResult = new CDO();
        cdoResult.set("isEndPage", isEndPage);
        cdoResult.set("datalist", cdoMapperResultList);
//        int total = venusOaControlOverInvoicesDao.getVenusOaControlOverInvoicesCount(cdoRequest);
//        cdoResult.set("total", total);
        return Return.valueOf(cdoResult);
    }
}
